
package kaizone.haining.chaobohui.json;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public class Item {
    
    public static final String CANSIGNUP_F = "F";

    public static final String CANSIGNUP_T = "T";

    public static final String COMMENTCOUNT = "commentCount";

    public static final String CONTACTNAME = "contactName";

    public static final String CONTACTPHONE = "contactPhone";

    public static final String COUNTESYREMINDER = "countesyReminder";

    public static final String FOLLOWCOUNT = "followCount";

    public static final String CHECKINCOUNT = "checkinCount";

    public static final String GMTACTIVITY = "gmtActivity";

    public static final String GMTACTIVITYSTART = "gmtActivityStart";

    public static final String GMTACTIVITYEND = "gmtActivityEnd";

    public static final String GMTCREATE = "gmtCreate";

    public static final String GMTMODIFIED = "gmtModified";

    public static final String ID = "id";

    public static final String INTRO = "intro";

    public static final String ISUSERFOLLOWED = "isUserFollowed";

    public static final String LOCATION = "location";

    public static final String NAME = "name";

    public static final String NOTICE = "notice";

    public static final String PICMODEL = "picModel";

    public static final String PICMODELLIST = "picModelList";

    public static final String PICURLLIST = "picUrlList";

    public static final String PICURLS = "picUrls";

    public static final String STANDPICMODELLIST = "standPicModelList";

    public static final String STANDPICURLLIST = "standPicUrlList";

    public static final String STANDPICURLS = "standPicUrls";

    public static final String SUBJECT = "subject";

    public static final String SUBJECTID = "subjectId";

    public static final String CANSIGNUP = "canSignup";

    private int commentCount;

    private String contactName;

    private String contactPhone;

    private String countesyReminder;

    private int followCount;

    private int checkinCount;

    private String gmtActivity;

    private String gmtActivityStart;

    private String gmtActivityEnd;

    private String gmtCreate;

    private String gmtModified;

    private int id;

    private String intro;

    private String isUserFollowed;

    private String location;

    private String name;

    private String notice;

    private PicModel picModel;

    private List<PicModel> picModelList;

    private List<String> picUrlList;

    private String picUrls;

    private List<PicModel> standPicModelList;

    private List<String> standPicUrlList;

    private String standPicUrls;

    private Object subject;

    private int subjectId;

    private String canSignup;

    public static class PicModel implements Serializable {
        /**
         * 
         */
        private static final long serialVersionUID = -2L;

        public static final String PATH = "path";

        public static final String SUM100X000 = "sum100x000";

        public static final String URL = "url";

        public String path;

        public String sum100x000;

        public String url;

        @Override
        public String toString() {
            return "path:" + path + ",url:" + url + ",sum100x000:" + sum100x000;
        }
    }

    public int getCommentCount() {
        return commentCount;
    }

    public void setCommentCount(int commentCount) {
        this.commentCount = commentCount;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    public String getCountesyReminder() {
        return countesyReminder;
    }

    public void setCountesyReminder(String countesyReminder) {
        this.countesyReminder = countesyReminder;
    }

    public int getFollowCount() {
        return followCount;
    }

    public void setFollowCount(int followCount) {
        this.followCount = followCount;
    }

    public int getCheckinCount() {
        return checkinCount;
    }

    public void setCheckinCount(int checkinCount) {
        this.checkinCount = checkinCount;
    }

    public String getGmtActivity() {
        return gmtActivity;
    }

    public void setGmtActivity(String gmtActivity) {
        this.gmtActivity = gmtActivity;
    }

    public String getGmtActivityStart() {
        return gmtActivityStart;
    }

    public void setGmtActivityStart(String gmtActivityStart) {
        this.gmtActivityStart = gmtActivityStart;
    }

    public String getGmtActivityEnd() {
        return gmtActivityEnd;
    }

    public void setGmtActivityEnd(String gmtActivityEnd) {
        this.gmtActivityEnd = gmtActivityEnd;
    }

    public String getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(String gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(String gmtModified) {
        this.gmtModified = gmtModified;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getIsUserFollowed() {
        return isUserFollowed;
    }

    public void setIsUserFollowed(String isUserFollowed) {
        this.isUserFollowed = isUserFollowed;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNotice() {
        return notice;
    }

    public void setNotice(String notice) {
        this.notice = notice;
    }

    public PicModel getPicModel() {
        return picModel;
    }

    public void setPicModel(PicModel picModel) {
        this.picModel = picModel;
    }

    public List<PicModel> getPicModelList() {
        return picModelList;
    }

    public void setPicModelList(List<PicModel> picModelList) {
        this.picModelList = picModelList;
    }

    public List<String> getPicUrlList() {
        return picUrlList;
    }

    public void setPicUrlList(List<String> picUrlList) {
        this.picUrlList = picUrlList;
    }

    public String getPicUrls() {
        return picUrls;
    }

    public void setPicUrls(String picUrls) {
        this.picUrls = picUrls;
    }

    public List<PicModel> getStandPicModelList() {
        return standPicModelList;
    }

    public void setStandPicModelList(List<PicModel> standPicModelList) {
        this.standPicModelList = standPicModelList;
    }

    public List<String> getStandPicUrlList() {
        return standPicUrlList;
    }

    public void setStandPicUrlList(List<String> standPicUrlList) {
        this.standPicUrlList = standPicUrlList;
    }

    public String getStandPicUrls() {
        return standPicUrls;
    }

    public void setStandPicUrls(String standPicUrls) {
        this.standPicUrls = standPicUrls;
    }

    public Object getSubject() {
        return subject;
    }

    public void setSubject(Object subject) {
        this.subject = subject;
    }

    public int getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(int subjectId) {
        this.subjectId = subjectId;
    }

    public String getCanSignup() {
        return canSignup;
    }

    public void setCanSignup(String canSignup) {
        this.canSignup = canSignup;
    }

    public void setItem(Item item) {
        commentCount = item.getCommentCount();
        contactName = item.getContactName();
        contactPhone = item.getContactPhone();
        countesyReminder = item.getCountesyReminder();
        followCount = item.getFollowCount();
        gmtActivity = item.getGmtActivity();
        gmtCreate = item.getGmtCreate();
        gmtModified = item.getGmtModified();
        id = item.getId();
        intro = item.getIntro();
        isUserFollowed = item.getIsUserFollowed();
        location = item.getLocation();
        name = item.getName();
        notice = item.getNotice();
        picModel = item.getPicModel();
        picModelList = item.getPicModelList();
        picUrlList = item.getPicUrlList();
        standPicModelList = item.getStandPicModelList();
        standPicUrlList = item.getStandPicUrlList();
        standPicUrls = item.getStandPicUrls();
        subject = item.getSubject();
        subjectId = item.getSubjectId();
        canSignup = item.getCanSignup();
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@").append("\n");
        sb.append("commentCount").append(":").append(commentCount).append("\n");
        sb.append("contactName").append(":").append(contactName).append("\n");
        sb.append("contactPhone").append(":").append(contactPhone).append("\n");
        sb.append("countesyReminder").append(":").append(countesyReminder).append("\n");
        sb.append("followCount").append(":").append(followCount).append("\n");
        sb.append("gmtActivity").append(":").append(gmtActivity).append("\n");
        sb.append("gmtCreate").append(":").append(gmtCreate).append("\n");
        sb.append("gmtModified").append(":").append(gmtModified).append("\n");
        sb.append("id").append(":").append(id).append("\n");
        sb.append("intro").append(":").append(intro).append("\n");
        sb.append("isUserFollowed").append(":").append(isUserFollowed).append("\n");
        sb.append("location").append(":").append(location).append("\n");
        sb.append("name").append(":").append(name).append("\n");
        sb.append("notice").append(":").append(notice).append("\n");
        sb.append("picUrls").append(":").append(picUrls).append("\n");
        sb.append("standPicUrls").append(":").append(standPicUrls).append("\n");
        sb.append("subject").append(":").append(subject).append("\n");
        sb.append("subjectId").append(":").append(subjectId).append("\n");
        try {
            sb.append("picModelList").append(":").append(picModelList.toString()).append("\n");
            sb.append("picUrlList").append(":").append(picUrlList.toString()).append("\n");
            sb.append("standPicModelList").append(":").append(standPicModelList.toString())
                    .append("\n");
            sb.append("standPicUrlList").append(":").append(standPicUrlList.toString())
                    .append("\n");
        } catch (Exception e) {
            // e.printStackTrace();
        }
        return sb.toString();
    }

    public static Item parse(JSONObject jsonObject) {
        Item item = new Item();

        item.setCommentCount(jsonObject.optInt(Item.COMMENTCOUNT));
        item.setContactName(jsonObject.optString(Item.CONTACTNAME));
        item.setContactPhone(jsonObject.optString(Item.CONTACTPHONE));
        item.setCountesyReminder(jsonObject.optString(Item.COUNTESYREMINDER));
        item.setFollowCount(jsonObject.optInt(Item.FOLLOWCOUNT));
        item.setGmtActivity(jsonObject.optString(Item.GMTACTIVITY));
        item.setGmtActivityStart(jsonObject.optString(Item.GMTACTIVITYSTART));
        item.setGmtActivityEnd(jsonObject.optString(Item.GMTACTIVITYEND));
        item.setGmtCreate(jsonObject.optString(Item.GMTCREATE));
        item.setGmtModified(jsonObject.optString(Item.GMTMODIFIED));
        item.setId(jsonObject.optInt(Item.ID));
        item.setIntro(jsonObject.optString(Item.INTRO));
        item.setIsUserFollowed(jsonObject.optString(Item.ISUSERFOLLOWED));
        item.setLocation(jsonObject.optString(Item.LOCATION));
        item.setName(jsonObject.optString(Item.NAME));
        item.setNotice(jsonObject.optString(Item.NOTICE));
        item.setPicUrls(jsonObject.optString(Item.PICURLS));
        item.setStandPicUrls(jsonObject.optString(Item.STANDPICURLS));
        item.setSubjectId(jsonObject.optInt(Item.SUBJECTID));
        item.setCheckinCount(jsonObject.optInt(Item.CHECKINCOUNT));
        item.setCanSignup(jsonObject.optString(CANSIGNUP));
        // item.setSubject(jsonObject.optString(Item.SUBJECT));

        JSONObject jsonSubject = jsonObject.optJSONObject(Item.SUBJECT);
        if (jsonSubject != null) {
            SubjectItem suj = SubjectItem.parse(jsonSubject);
            item.setSubject(suj);
        }

        JSONObject jsonPic = jsonObject.optJSONObject(Item.PICMODEL);
        if (jsonPic != null) {
            PicModel picModel = new PicModel();
            picModel.path = jsonPic.optString(PicModel.PATH);
            picModel.sum100x000 = jsonPic.optString(PicModel.SUM100X000);
            picModel.url = jsonPic.optString(PicModel.URL);
            item.setPicModel(picModel);
        }

        JSONArray jsonPicModes = jsonObject.optJSONArray(Item.PICMODELLIST);
        if (jsonPicModes != null) {
            ArrayList<PicModel> picmodels = new ArrayList<Item.PicModel>();
            int picmodesLen = jsonPicModes.length();
            for (int j = 0; j < picmodesLen; j++) {
                JSONObject jsonPicmodeObj = jsonPicModes.optJSONObject(j);
                PicModel picModel = new PicModel();
                picModel.path = jsonPicmodeObj.optString(PicModel.PATH);
                picModel.sum100x000 = jsonPicmodeObj.optString(PicModel.SUM100X000);
                picModel.url = jsonPicmodeObj.optString(PicModel.URL);
                picmodels.add(picModel);
            }
            item.setPicModelList(picmodels);
        }

        JSONArray jsonPicUrls = jsonObject.optJSONArray(Item.PICURLLIST);
        if (jsonPicUrls != null) {
            ArrayList<String> picurlList = new ArrayList<String>();
            int picUrlLen = jsonPicUrls.length();
            for (int j = 0; j < picUrlLen; j++) {
                String picUrl = jsonPicUrls.optString(j);
                picurlList.add(picUrl);
            }
            item.setStandPicUrlList(picurlList);
        }

        JSONArray jsonstandPicModes = jsonObject.optJSONArray(Item.PICMODELLIST);
        if (jsonPicModes != null) {
            ArrayList<PicModel> picmodels = new ArrayList<Item.PicModel>();
            int picmodesLen = jsonstandPicModes.length();
            for (int j = 0; j < picmodesLen; j++) {
                JSONObject jsonPicmodeObj = jsonstandPicModes.optJSONObject(j);
                PicModel picModel = new PicModel();
                picModel.path = jsonPicmodeObj.optString(PicModel.PATH);
                picModel.url = jsonPicmodeObj.optString(PicModel.URL);
                picmodels.add(picModel);
            }
            item.setStandPicModelList(picmodels);
        }

        JSONArray jsonstandPicUrls = jsonObject.optJSONArray(Item.PICURLLIST);
        if (jsonPicUrls != null) {
            ArrayList<String> picurlList = new ArrayList<String>();
            int picUrlLen = jsonstandPicUrls.length();
            for (int j = 0; j < picUrlLen; j++) {
                String picUrl = jsonstandPicUrls.optString(j);
                picurlList.add(picUrl);
            }
            item.setStandPicUrlList(picurlList);
        }

        return item;
    }
}
